﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UWP.Douban.Api;
using UWP.Douban.Models;
using Windows.UI.Xaml.Navigation;

namespace UWP.Douban.Mvvm
{
    public class MeVm : BaseVm
    {

        private UserInfo _userInfo;

        public MeVm()
        {

        }

        public UserInfo UserInfo
        {
            get { return _userInfo; }
            set
            {
                if (_userInfo == value) return;
                _userInfo = value;
                OnPropertyChanged();
            }
        }

        public string LikeTopicTitle
        {
            get
            {
                if (UserInfo != null)
                {
                    return $"{UserInfo.User.Name}喜欢的话题({UserInfo.LikeTopicCount})";
                }
                return "喜欢的话题";
            }
        }
        public string ReplyTopicTitle
        {
            get
            {
                if (UserInfo != null)
                {
                    return $"{UserInfo.User.Name}回复的话题({UserInfo.ReplyTopicCount})";
                }
                return "回复的话题";
            }
        }
        public string UserTopicTitle
        {
            get
            {
                if (UserInfo != null)
                {
                    return $"{UserInfo.User.Name}发表的话题({UserInfo.AlbumCount})";
                }
                return "发表的话题";
            }
        }
        public string RecommendedTopicTitle
        {
            get
            {
                if (UserInfo != null)
                {
                    return $"{UserInfo.User.Name}推荐的话题({UserInfo.RecTopicCount})";
                }
                return "推荐的话题";
            }
        }
        public string JoindGroupTitle
        {
            get
            {
                if (UserInfo != null)
                {
                    return $"{UserInfo.User.Name}加入的小组({UserInfo.JoinGroupCount})";
                }
                return "加入的小组";
            }
        }

        public override async void OnNavigatedTo(NavigationEventArgs e)
        {
            UserInfo = await GroupApi.UserInfoGet(Common.UserId);
            //UserInfo = await SampleData.SampleDataUtil.GetMe();

            base.OnNavigatedTo(e);
        }
    }
}
